import time

from selenium import webdriver
from selenium.webdriver.common.by import By


def demo_1():
    dirver=webdriver.Chrome()
    dirver.get("https://ceshiren.com/")
    time.sleep(1)
    dirver.find_element(By.CSS_SELECTOR,"#ember6 > header > div > div > div.panel.clearfix > span > button.widget-button.btn.btn-primary.btn-small.login-button.btn-icon-text > span").click()
    time.sleep(1)
    dirver.find_element(By.ID, "login-account-name").send_keys("3211473463@qq.com")
    time.sleep(1)
    dirver.find_element(By.ID, "login-account-password").send_keys("hogwarts")
    time.sleep(1)
    dirver.find_element(By.CSS_SELECTOR, "#login-button > span").click()
    time.sleep(3)

    dirver.find_element(By.ID,"search-button").click()
    time.sleep(1)
    dirver.find_element(By.ID,"search-term").send_keys("ChromeDriver")
    time.sleep(1)
    dirver.find_element(By.CSS_SELECTOR,".widget-link.show-advanced-search").click()
    time.sleep(1)

    dirver.find_element(By.CSS_SELECTOR,"#search-in-category-header").click()
    time.sleep(1)
    dirver.find_element(By.CSS_SELECTOR,"#search-in-category-body>.select-kit-collection>li:nth-child(1)").click()
    time.sleep(1)

    dirver.find_element(By.CSS_SELECTOR,"#search-status-options-header").click()
    time.sleep(1)
    dirver.find_element(By.CSS_SELECTOR,"#search-status-options-body>.select-kit-collection>li:nth-child(1)").click()
    time.sleep(1)

    dirver.find_element(By.XPATH,"//*[text()='搜索']").click()
    time.sleep(3)
    a=dirver.find_element(By.CSS_SELECTOR,".fps-result-entries>div:nth-child(1)>div:nth-child(2)>div:nth-child(1)>.search-link.visited>span>span")
    assert "ChromeDriver" in a.text


if __name__ == '__main__':
    demo_1()